package cn.edu.scau.cmi.guihao.controller;

import java.util.ArrayList;
import java.util.List;
import java.util.Observable;

import cn.edu.scau.cmi.guihao.factory.AllTypeInsurance;
import cn.edu.scau.cmi.guihao.interProgramming.factory.Insurance;
import cn.edu.scau.cmi.guihao.interProgramming.factory.InsuranceType;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextArea;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.text.Text;

public class FactoryController {

	@FXML
	private Text name;
	
	@FXML
	private ComboBox<String> selectInsuranceType;
	
	@FXML
	private TextArea displayMessage;
	
	@FXML
	private ImageView photoView;
	
	public void Init() {
		ObservableList<String> type = FXCollections.observableArrayList("身体受伤","汽车损坏");
		selectInsuranceType.setItems(type);
		Image image = new Image("/cn/edu/scau/cmi/guihao/img/timg.jpg");
		photoView.setImage(image);
	}
	
	@FXML
	public void onBtnClick() {
		System.out.println(selectInsuranceType.getValue()+"   "+name.getText());
		Insurance insurance = AllTypeInsurance.createInsurance(selectInsuranceType.getValue());
		InsuranceType insuranceType = insurance.createInsurance(name.getText());
		displayMessage.setText(insuranceType.compensate());
	}

	
	
}
